|
|
|
|
|
|
|
Listing 19.23. Coding the general declaration section of the form. |
|
|
|
|
|
|
|
|
Option Explicit
'
' form-level vars
Dim objSQL As Object
Dim blnAdding As Boolean |
|
|
|
|
|
|
|
|
Next, you need to create a custom routine that sets the new class properties and initializes the data connection. Create a new Public Sub called StartDB and enter the code in Listing 19.24. |
|
|
|
|
|
|
|
|
Listing 19.24. Coding the StartDB routine. |
|
|
|
|
|
|
|
|
Public Sub StartDB()
'
' handle chores of connecting and getting data
'
' create reference to ODBC object
Set objSQL = New objODBC
'
' populate properties
objSQL.DataSource = "ODBC API Test"
objSQL.UserID = "admin"
objSQL.Password = ""
objSQL.SQL = "SELECT * FROM TestTable"
objSQL.Table = "TestTable"
objSQL.Key = "Name"
objSQL.ResultSetType = sqlStatic
objSQL.CursorDriver = sqlUseODBC
objSQL.LockType = sqlValues
'
' do real work
objSQL.Connect ' establish connection
objSQL.Refresh ' build dataset
objSQL.MoveFirst Me ' display first row
'
End Sub |
|
|
|
|
|
|
|
|
Most of the material here should look familiar. After creating a reference to the class and setting several properties, the Connect, Refresh, and MoveFirst methods are executed to fill the form with data. |
|
|
|
|
|